const express = require('express')
const app = new express();

/**访问统计
统计访问者的访问时间
把访问时间格式化成 YYYY-MM-DD hh: mm: sS
通过路由输出到页面上
**/

const setServer = (req,res,next)=>{

    const server ={
        name:'test',
        port:3000
    }

    req.server= server;
    next()
}

app.use(setServer) // 注册中间件


const server = app.listen(3000,'localhost',(req,res)=>{
    const address = server.address();
    console.log(" This is http://%s:%s",address.address,address.port)
})
